<template>
  <div class="main">
    <div class="user_info">
      <div class="user_pic"><img src="../../assets/images/icon/img-headpic.png"/></div>
      <div class="user_msg">
        <ul>
          <li class="socialName">商丘人社</li>
          <li>姓名： {{data.aac003}}</li>
          <li>性别： {{data.aac004}}</li>
          <li>身份证： {{data.aac002}}</li>
          <li>卡状态：{{data.aaz502}}</li>
        </ul>
      </div>
    </div>
    <!--<div class="tip">社保局预留手机号：<span>{{phone}}</span></div>-->
    <!--<div class="yzm">-->
    <!--<label>社保卡密码：</label>-->
    <!--<input type="password" placeholder="请输入密码" v-model="password"/>-->
    <!--&lt;!&ndash;<input type="button" value="获取验证码" :disabled="!yzmStatue" @click="sendYZM"/>&ndash;&gt;-->
    <!--</div>-->
    <div>
      <input v-show="data.aaz502=='OK'" @click="lossLink" class="btn_sure" type="button" value="申请挂失"/>
      <input v-show="data.aaz502=='临时挂失'" @click="relieveLoss" class="btn_sure" type="button" value="解除挂失"/>
    </div>
    <div class="time_tip">社保卡<span>挂失有效期为5天。</span></div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        data: {},
        password: "",
        userInfo: this.utils.getUser()
      }
    },
    methods: {
      //获取社保卡信息
      getData(){
        this.$http.post("transmit", {
          "access_token": this.utils.getToken(),
          "transmitUrl": "/ssCardMgr/cardInfoQuery",
          "method": "get",
          "objectId": "f4860abe5e8e49eca2725360f0c65c6c",
          "objectType": "1"
        }).then(res => {
          console.log(res);
          if (res.success) {
					    switch (res.body.aaz502) {
					      case "OK":
					        res.body.aaz502 = '正常状态'
					        break;
					      default:
					        res.body.aaz502 = '状态异常'
					    }
            this.data = res.body;
          }
        });
      },
      lossLink(){
        this.$message.confirm('确定申请挂失吗?').then(action => {
          if (action == "confirm") {
            let xmldata = "<操作*>临时挂失</操作*><用户名*>411400ZHRS</用户名*><密码*>411400ZHIhrsApp</密码*><城市代码*>419900</城市代码*><社会保障卡卡号*>" + this.userInfo.cardnum
              + "</社会保障卡卡号*><社会保障号码*>" + this.userInfo.certnum
              + "</社会保障号码*><姓名*>" + this.userInfo.name + "</姓名*>";
            this.$http.post("transmit", {
              "access_token": this.utils.getToken(),
              "transmitUrl": "/ssCardMgr/cardLoss",
              "method": "post",
              "objectId": "94dfa5cae5274b39ac2a9662101c1e8d",
              "objectType": "1",
              "inputParamXml": xmldata
            }).then(res => {
              console.log(res)
              if (res.success) {
                this.$router.push({path: '/reportSuccess', query: {token: this.token}})
              }
            });
          }
        }).catch(err => {
        });
      },
      relieveLoss(){
        this.$message.confirm('确定解除挂失吗?').then(action => {
          if (action == "confirm") {
            let xmldata = "<操作*>解除挂失</操作*><用户名*>411400ZHRS</用户名*><密码*>411400ZHIhrsApp</密码*><城市代码*>419900</城市代码*><社会保障卡卡号*>" + this.userInfo.cardnum
              + "</社会保障卡卡号*><社会保障号码*>" + this.userInfo.certnum
              + "</社会保障号码*><姓名*>" + this.userInfo.name + "</姓名*>";
            this.$http.post("transmit", {
              "access_token": this.utils.getToken(),
              "transmitUrl": "ssCardMgr/cardRelieveLoss",
              "method": "post",
              "objectId": "94dfa5cae5274b39ac2a9662101c1e8d",
              "objectType": "1",
              "inputParamXml": xmldata
            }).then(res => {
              console.log(res)
              if (res.success) {
                this.$toast({
                  message: "解挂成功",
                  duration: 3000
                });
                this.getData();
              }
            });
          }
        }).catch(err => {
        });
      },
    },
    created(){
      this.getData();
    }
  }
  document.body.style.background = "#F2F2F2"
</script>

<style lang="less" scoped>
  .main {
    max-width: 786px;
    margin: 0 auto;
    width: 100%;
    text-align: center;
  }

  .last {
    display: block;
    width: 30%;
    height: 33px;
    position: absolute;
    top: 61%;
    left: 30%;
    z-index: 1;
  }

  .user_info {
    overflow: hidden;
    width: 90%;
    margin: 10px auto 0;
    background: url("../../assets/images/social/bg-card.png") no-repeat;
    background-size: 100% 100%;
  }

  .loss {
    overflow: hidden;
    width: 90%;
    margin: 10px auto 0;
    background: url("../../assets/images/social/bg_card_loss.png") no-repeat;
    background-size: 100% 100%;
  }

  .user_info > div {
    float: left;
  }

  .user_pic {
    height: 48px;
    width: 48px;
    border-radius: 50%;
    overflow: hidden;
    margin-left: 22px;
    margin-top: 62px;
  }

  .user_pic img {
    width: 100%;
    height: 100%;
  }

  li {
    list-style: none;
    text-align: left;
    line-height: 23px;
    font-size: 13px;
  }

  .user_msg {
    font-size: 12px;
    width: 75%;
  }

  .user_msg ul {
    margin-top: 18px;
    color: #FFF;
    margin-left: 6%;
  }

  .user_msg li:first-child {
    font-size: 15px;
    line-height: 36px;
    color: #F8E71C;
  }

  .user_msg li:last-child {
    padding: 0 0 42px;
    font-size: 12px;
  }

  .tip {
    font-size: 14px;
    color: #1F1F1F;
    height: 51px;
    line-height: 51px;
    text-align: left;
    margin-left: 4%;
  }

  .tip span, .time_tip span {
    color: #F65150;
  }

  .yzm {
    background: #FFF;
    height: 51px;
    line-height: 51px;
    text-align: left;
    font-size: 0;
  }

  .yzm label {
    display: inline-block;
    width: 30%;
    font-size: 14px;
    color: #333333;
    margin-left: 4%;
  }

  .yzm input[type=password] {
    width: 50%;
    height: 34px;
    border: none;
    font-size: 14px;
  }

  .yzm input[type=button] {
    width: 30%;
    height: 34px;
    background: #FFFFFF;
    border: 0;
    border-radius: 4px;
    font-size: 15px;
    color: #3399ff;
  }

  .yzm input[type=button]:disabled {
    background: #ccc;
    color: #888;
    border-radius: 3px;
  }

  .btn_sure {
    -webkit-appearance: none;
    outline: none;
    width: 90%;
    height: 48px;
    border: none;
    color: #FFF;
    font-size: 18px;
    margin: 30px auto;
    background: #3399FF;
    border-radius: 4px;
  }

  .time_tip {
    font-size: 14px;
    text-align: left;
    margin-left: 4%;
    color: #888888;
  }

  input {
    -webkit-appearance: none;
    outline: none;
  }
</style>
